<?php 
namespace CLUB\Controller;
use Think\Controller;
/**
* 比赛业务
*/
class GameController extends PubController
{
	public function gamelist(){
	   $g = M("Game");
	   $count = $g -> count();
	   $pagesize = 15;
	   $Page = new \Think\Page($count,$pagesize);// 实例化分页类 传入总记录数和每页显示的记录数
	   $list = $g->limit($Page->firstRow.','.$Page->listRows)->select();
	   $Page->setConfig('prev', '上一页');
       $Page->setConfig('next', '下一页');
	   $show = $Page -> show();
	   $this -> assign('gamelist',$list);
	   $this -> assign("page",$show);
	   $this -> display();
	}
	public function addgame(){
	  $this -> display();
	}
	public function newgame(){
		$g = M("Game");
		$g->gname=I('post.gname');
		$g->gdata=I('post.gdata');
		$g->clubid = $_SESSION['clubid'];
		$g->gpic=$this->uploadfile($_FILES['gpic'],'./Public/upload/');
		if(false!=$g->add()){
			$this->redirect('Game/gamelist','',2,'添加成功，页面跳转中...');
		}else{
			$this->error("哎呀！出错了");
		}
	}
}